<template>
  <view class="my-total">
    <view class="left">
      <radio @click="changeAll" :checked="isCheckAll" color="#c00000"></radio>全选
    </view>
    <view class="center">
      合计：<text>￥ {{total_price | tofixed}}</text>
    </view>
    <view class="right">
      <button>结算({{total}})</button>
    </view>
  </view>
</template>

<script>
  import {mapGetters,mapMutations} from 'vuex'
  export default {
    name:"my-total",
    data() {
      return {
        
      };
    },
    filters: {
      // 把数字处理为带两位小数点的数字
      tofixed(num) {
        return Number(num).toFixed(2)
      }
    },
    computed:{
      ...mapGetters('cart',['total','isCheckAll','total_price'])
    },
    methods:{
      ...mapMutations('cart',['checkAllStatus']),
      // 点击全选会触发
      changeAll(){
        this.checkAllStatus(!this.isCheckAll)
      }
    }
  }
</script>

<style lang="scss">
.my-total{
  position: fixed;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  width: 100%;
  height: 45px;
  line-height: 40px;
  padding: 0 10px;
  border-top: 1px solid #ccc;
  background-color: #fff;
  .left{
    width: 100px;
  }
  .center{
    flex: 1.5;
    text{
      color: #c00000;
    }
  }
  .right{
    flex: 1;
    button{
      background-color: #c00000;
      font-size: 14px;
      color: #fff;
      width: 120px;
      height: 45px;
      line-height: 45px;
    }
  }
}
</style>